<?php
namespace Tbf\Bundle\AlipayBundle;
use Tbf\Bundle\AlipayBundle\Model\CreatePaymentRequest;
use Tbf\Bundle\AlipayBundle\Model\SendGoodsConfirmByPlatFormRequest;
use Tbf\Bundle\TbfBundle\DependencyInjection\TbfContainerAware;

/**
 * 支付宝组件入口
 */
class Manager extends TbfContainerAware{
    function newCreatePaymentRequest($input){
        return new CreatePaymentRequest($input);
    }
    function newSendGoodsConfirmByPlatFormRequest(){
        return new SendGoodsConfirmByPlatFormRequest();
    }
    /**
     * 发起即时到帐交易,请将返回的response返回给controller
     * @param CreatePaymentRequest $request
     * @return array
     * func(request CreatePaymentRequest)(response Response,err error)
     */
    function createDirectPayByUser(CreatePaymentRequest $request){
        return $this->get('tbf_alipay.create_direct_pay_by_user')->request($request);
    }

    /**
     * 发起双接口交易,请将返回的response返回给controller
     * @param CreatePaymentRequest $request
     * @return array
     * func(request CreatePaymentRequest)(response Response,err error)
     */
    function createTradeByUser(CreatePaymentRequest $request){
        return $this->get('tbf_alipay.create_trade_by_user')->request($request);
    }

    /**
     * 发起纯担保交易,请将返回的response返回给controller
     * @param CreatePaymentRequest $request
     * @return array
     * func(request CreatePaymentRequest)(response Response,err error)
     */
    function createPartnerTradeByBuyer(CreatePaymentRequest $request){
        return $this->get('tbf_alipay.create_partner_trade_by_buyer')->request($request);
    }

    /**
     * 确认发货接口,
     * 仅仅是一个普通的ajax请求
     * @param SendGoodsConfirmByPlatFormRequest $request
     * @return \Tbf\Bundle\AlipayBundle\Model\SendGoodsConfirmByPlatFormResponse
     */
    function sendGoodsConfirmByPlatform(SendGoodsConfirmByPlatFormRequest $request){
        return $this->get('tbf_alipay.send_goods_confirm_by_platform')->request($request);
    }
}
